<%@ page language="java" contentType="text/html; charset=UTF-8"	%>
<%@ include file="/basecore/taglibs.jsp"%>
<%int id=Math.abs(new java.util.Random().nextInt());%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>数据权限设置</title>
		<%@ include file="/basecore/meta.jsp"%>	
		<script>
			function readTarget(){
				var items = parent.document.getElementsByName("${target}");				
			    if(typeof items=="object"){
			    	if(typeof items.length =="number"){
			    		for (var i = 0; i < items.length; i++){
			    			var target=items[i].value;			    			
			    			if(typeof target=="string" && target.indexOf("|")<1){		
			    				targetname=getObject(parent.document,target).value;			    				
			    				if(typeof targetname =="string")	    				
			    					target=target+"|"+targetname;
			    				else
			    					target=target+"|";
			    			}
			        		if (items[i].checked == true && typeof target=="string"){
			        			if(getObject("target_value1").value=="")
			        				getObject("target_value1").value=target;
			        			else
			            			getObject("target_value1").value=getObject("target_value1").value+","+target;
			        		}
			    		}
			    	}else{
			    		if(document.all.itemlist.checked==true){
			    			var target=items[i].value;
			    			if(typeof target=="string" && target.indexof("|")<1){
			    				targetname=getObject(parent.document,target).value;			    				
			    				if(typeof targetname =="string")	    				
			    					target=target+"|"+targetname;
			    				else
			    					target=target+"|";
			    			}
			    			if(typeof target=="string")
			    				getObject("target_value1").value=target;
			    		}
			    	}
			    }			   
			}
		</script>			
	</head>
	<body onload="readTarget()">		
		<form name="form1" id="form1" action="dataSetAuthSetController!store.wit" method="post">
			<a href="#" onclick="if(FormValidator.validate(form1,2))form1.submit();" accesskey="s" title="保存数据"><img class="img16" src="${contextPath}/webresource/images/save.png" /> 
			保存(S)</a>					
			<a href="javascript:parent.history.back(-1)" accesskey="b" title="返回上一页">
			<img class="img16" src="${contextPath}/webresource/images/toolbar/return_to_list.jpeg" >
			返回(B)</a>
			<input name="category" id="category" value="${category}" type="hidden">
			<input name="user_<%=id%>" id="user_<%=id%>" value="t1=user_id;t2=user_name;" type="hidden"/>
			<input type="hidden" name="user_id" id="user_id">
			<input type="hidden" name="user_name" id="user_name">
			<input type="hidden" id="selected" name="selected" value="${selected}"/>
			<input type="hidden" id="selectedItems" name="selectedItems" value="${selectedItems}"  dataType="Require"  msg="尚未选择任何授权数据"/>
			<input type="hidden" name="target_value1"  id="target_value1" value="${target_value1}" />
			<input type="hidden" name="target_value"  id="target_value" value="${target_value}" />
					
			<table width="95%" style="cellspacing: 0px;cellpadding: 0px;">				
				<tr>
					<td valign="top">
					<B>用户</B>
						  <wit:dataSetAuthSelectTree 
						  	treeid="user_<%=id%>"
						    data="select id,username from AD_USER"
						    data2="select id,name,ad_org_id from AD_ORG" root="0" parentid="AD_ORG_ID" parentid2="AD_ORG_ID"
						    nodeid="id" nodelabel="username" nodeid2="id" nodelabel2="name"
						    datatype="sql" multiple="1" width="270" height="${height-120}"
	    					/>
					</td>
					<td valign="top"> 
					<B>权限项</B>
						<wit:dataSetAuthSelect width="${width-260-60}" height="${height-120}"
						id="dataset_<%=id%>"
						data="${data}" datatype="${datatype}"
						properties="${entryname}" multiple="${multiple}" property1="${entryid}" property2="${entryname}" property3="${category}"
						titles="${titles}"
						/>
					</td>
				</tr>
			</table>
			
			
			<input type="hidden" name="data" value="${data}"/>
			<input type="hidden" name="properties" value="${properties}"/>
			<input type="hidden" name="category" value="${category}"/>
			<input type="hidden" name="entryid" value="${entryid}"/>
			<input type="hidden" name="entryname" value="${entryname}"/>
			<input type="hidden" name="datatype" value="${datatype}"/>
			<input type="hidden" name="datastyle" value="${datastyle}"/>	
			<input type="hidden" name="titles" value="${titles}"/>	
			<input type="hidden" name="multiple" value="${multiple}"/>	
			
			<input type="hidden" name="data2" value="${data2}"/>
			<input type="hidden" name="root" value="${root}"/>
			<input type="hidden" name="parentid" value="${parentid}"/>
			<input type="hidden" name="nodeid" value="${nodeid}"/>
			<input type="hidden" name="nodeid2" value="${nodeid2}"/>
			<input type="hidden" name="nodelabel" value="${nodelabel}"/>
			<input type="hidden" name="nodelabel2" value="${nodelabel2}"/>
			<input type="hidden" name="onlyLeaf" value="${onlyLeaf}"/>
			<input type="hidden" name="height" value="${height}"/>
			<input type="hidden" name="width" value="${width}"/>			
			
			<input type="hidden" name="filterOptions" value="${filterOptions}" />			
			</form>
	</body>
</html>